package com.aaa.sbm.controller;

import com.aaa.sbm.entity.Teacher;
import com.aaa.sbm.service.TeacherService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Teacher)表控制层
 *
 * @author makejava
 * @since 2020-11-12 15:01:35
 */
@RestController
@RequestMapping("teacher")
public class TeacherController {
    /**
     * 服务对象
     */
    @Resource
    private TeacherService teacherService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Teacher selectOne(Integer id) {
        return this.teacherService.queryById(id);
    }

    /**
     * 查询多条数据
     * @param offset   查询起始位置
     * @param limit  查询条数
     * @return   对象列表
     */
    @GetMapping("queryAllByLimit")
    public List<Teacher>  queryAllByLimit(int offset, int limit){
        return this.teacherService.queryAllByLimit(offset,limit);
    }

    /**
     * 根据属性查询所有
     * @param teacher
     * @return
     */
    @GetMapping("queryAll")
    public List<Teacher> queryAll(Teacher teacher){
        return this.teacherService.queryAll(teacher);
    }

    /**
     * 添加
     * @param teacher
     * @return
     */
    @PostMapping("insert")
    public Teacher insert(Teacher teacher){
        return this.teacherService.insert(teacher);
    }

    @PutMapping("update")
    public Teacher update(Teacher teacher){
        return this.teacherService.update(teacher);
    }

    @DeleteMapping("deleteById")
    public boolean deleteById(Integer id){
        return this.teacherService.deleteById(id);
    }

}